﻿namespace WMS6.SQLServerDAL
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Common;
    using System.Data.SqlClient;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.DBUtility;
    using WMS6.IDAL;
    using WMS6.QueryEntity;

    public class TrackingDetailDA : ITrackingDetailDA
    {
        private string ACCEPT_MODE = "@ACCEPT_MODE";
        private string BOL_ID = "@BOL_ID";
        private string CARRIER_ID = "@CARRIER_ID";
        private string CREATED_BY = "@CREATED_BY";
        private string DELIVERY_ORDER_ID = "@DELIVERY_ORDER_ID";
        private string DRIVER_ID = "@DRIVER_ID";
        private string DRIVER_PHONE = "@DRIVER_PHONE";
        private string EQUIPMENT_LICENCE = "@EQUIPMENT_LICENCE";
        private string REMARK = "@REMARK";
        private string ROAD_INFO = "@ROAD_INFO";
        private string SQL_CHECK_TRACKING_DETAIL_ID_UNIQUE = " SELECT COUNT(1) FROM @_@TRACKING_DETAIL WHERE TRACKING_ID = @TRACKING_ID ";
        private string SQL_DELETE_TRACKING_DETAIL = " DELETE FROM @_@TRACKING_DETAIL WHERE TRACKING_ID = @TRACKING_ID ";
        private string SQL_INSERT_TRACKING_DETAIL = " INSERT INTO @_@TRACKING_DETAIL ( WH_ID, TRACKING_ID, BOL_ID, DELIVERY_ORDER_ID, TRACKING_DATE, TRACKING_LOC, ACCEPT_MODE, ROAD_INFO, CARRIER_ID, EQUIPMENT_LICENCE, DRIVER_ID, DRIVER_PHONE, REMARK, UDF1, UDF2, UDF3, UDF4, UDF5, UDF6, UDF7, UDF8, UDF9, UDF10, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE) VALUES ( @WH_ID, @TRACKING_ID, @BOL_ID, @DELIVERY_ORDER_ID, @TRACKING_DATE, @TRACKING_LOC, @ACCEPT_MODE, @ROAD_INFO, @CARRIER_ID, @EQUIPMENT_LICENCE, @DRIVER_ID, @DRIVER_PHONE, @REMARK, @UDF1, @UDF2, @UDF3, @UDF4, @UDF5, @UDF6, @UDF7, @UDF8, @UDF9, @UDF10, @CREATED_BY, GETDATE(), @UPDATED_BY, GETDATE() )  ";
        private string SQL_SELECT_ALL_TRACKING_DETAIL = " SELECT  ROWID, WH_ID, TRACKING_ID, BOL_ID, DELIVERY_ORDER_ID, TRACKING_DATE, TRACKING_LOC, ACCEPT_MODE, ROAD_INFO, CARRIER_ID, EQUIPMENT_LICENCE, DRIVER_ID, DRIVER_PHONE, REMARK, UDF1, UDF2, UDF3, UDF4, UDF5, UDF6, UDF7, UDF8, UDF9, UDF10, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE  FROM  @_@TRACKING_DETAIL ";
        private string SQL_UPDATE_TRACKING_DETAIL = " UPDATE @_@TRACKING_DETAIL SET WH_ID = @WH_ID, BOL_ID = @BOL_ID, DELIVERY_ORDER_ID = @DELIVERY_ORDER_ID, TRACKING_DATE = @TRACKING_DATE, TRACKING_LOC = @TRACKING_LOC, ACCEPT_MODE = @ACCEPT_MODE, ROAD_INFO = @ROAD_INFO, CARRIER_ID = @CARRIER_ID, EQUIPMENT_LICENCE = @EQUIPMENT_LICENCE, DRIVER_ID = @DRIVER_ID, DRIVER_PHONE = @DRIVER_PHONE, REMARK = @REMARK, UDF1 = @UDF1, UDF2 = @UDF2, UDF3 = @UDF3, UDF4 = @UDF4, UDF5 = @UDF5, UDF6 = @UDF6, UDF7 = @UDF7, UDF8 = @UDF8, UDF9 = @UDF9, UDF10 = @UDF10, UPDATED_BY = @UPDATED_BY, UPDATED_DATE = GETDATE() WHERE TRACKING_ID = @TRACKING_ID  ";
        private string TRACKING_DATE = "@TRACKING_DATE";
        private string TRACKING_ID = "@TRACKING_ID";
        private string TRACKING_LOC = "@TRACKING_LOC";
        private string UDF1 = "@UDF1";
        private string UDF10 = "@UDF10";
        private string UDF2 = "@UDF2";
        private string UDF3 = "@UDF3";
        private string UDF4 = "@UDF4";
        private string UDF5 = "@UDF5";
        private string UDF6 = "@UDF6";
        private string UDF7 = "@UDF7";
        private string UDF8 = "@UDF8";
        private string UDF9 = "@UDF9";
        private string UPDATED_BY = "@UPDATED_BY";
        private string WH_ID = "@WH_ID";

        public bool CheckTrackingDetailIDUnique(string trackingDetailID, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@TRACKING_ID", trackingDetailID) };
            return (DBHelper.ExecuteScalar(CommandType.Text, this.SQL_CHECK_TRACKING_DETAIL_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public bool CheckTrackingDetailIDUnique(DataBase dataBase, DbTransaction tran, string trackingDetailID, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@TRACKING_ID", trackingDetailID) };
            return (dataBase.ExecuteScalar(tran, CommandType.Text, this.SQL_CHECK_TRACKING_DETAIL_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public int DeleteTrackingDetail(List<string> trackingDetailID, List<string> whLoginID)
        {
            int result = 0;
            DataBase dataBase = new DataBase();
            DbConnection conn = dataBase.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    for (int j = 0; j < trackingDetailID.Count; j++)
                    {
                        SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@TRACKING_ID", trackingDetailID[j]) };
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_TRACKING_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                conn.Close();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int DeleteTrackingDetail(DataBase dataBase, DbTransaction tran, List<string> trackingDetailID, List<string> whLoginID)
        {
            int result = 0;
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    for (int j = 0; j < trackingDetailID.Count; j++)
                    {
                        SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@TRACKING_ID", trackingDetailID[j]) };
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_TRACKING_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public DataSet GetAllTrackingDetail(string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_TRACKING_DETAIL.Replace("@_@", whLoginID);
            return DBHelper.ExecuteDataSet(CommandType.Text, sql);
        }

        public DataSet GetAllTrackingDetail(DataBase dataBase, DbTransaction tran, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_TRACKING_DETAIL.Replace("@_@", whLoginID);
            return dataBase.ExecuteDataSet(tran, CommandType.Text, sql);
        }

        public TrackingDetailInfo GetTrackingDetailByID(string trackingdetailID, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_TRACKING_DETAIL.Replace("@_@", whLoginID) + " WHERE TRACKING_ID = @TRACKING_ID  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@TRACKING_ID", trackingdetailID) };
            TrackingDetailInfo trackingDetailInfo = null;
            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                if (reader.Read())
                {
                    DateTime CS00003;
                    trackingDetailInfo = new TrackingDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["TRACKING_ID"].ToString(), reader["BOL_ID"].ToString(), reader["DELIVERY_ORDER_ID"].ToString(), (reader["TRACKING_DATE"].ToString() != "") ? DateTime.Parse(reader["TRACKING_DATE"].ToString()) : (CS00003 = new DateTime()), reader["TRACKING_LOC"].ToString(), reader["ACCEPT_MODE"].ToString(), reader["ROAD_INFO"].ToString(), reader["CARRIER_ID"].ToString(), reader["EQUIPMENT_LICENCE"].ToString(), reader["DRIVER_ID"].ToString(), reader["DRIVER_PHONE"].ToString(), reader["REMARK"].ToString(), reader["UDF1"].ToString(), reader["UDF2"].ToString(), reader["UDF3"].ToString(), reader["UDF4"].ToString(), reader["UDF5"].ToString(), reader["UDF6"].ToString(), reader["UDF7"].ToString(), reader["UDF8"].ToString(), reader["UDF9"].ToString(), reader["UDF10"].ToString(), reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00003 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime());
                }
            }
            return trackingDetailInfo;
        }

        public TrackingDetailInfo GetTrackingDetailByID(DataBase dataBase, DbTransaction tran, string trackingdetailID, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_TRACKING_DETAIL.Replace("@_@", whLoginID) + " WHERE TRACKING_ID = @TRACKING_ID  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@TRACKING_ID", trackingdetailID) };
            TrackingDetailInfo trackingDetailInfo = null;
            IDataReader reader = dataBase.ExecuteReader(tran, CommandType.Text, sql, paras);
            if (reader.Read())
            {
                DateTime CS00003;
                trackingDetailInfo = new TrackingDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["TRACKING_ID"].ToString(), reader["BOL_ID"].ToString(), reader["DELIVERY_ORDER_ID"].ToString(), (reader["TRACKING_DATE"].ToString() != "") ? DateTime.Parse(reader["TRACKING_DATE"].ToString()) : (CS00003 = new DateTime()), reader["TRACKING_LOC"].ToString(), reader["ACCEPT_MODE"].ToString(), reader["ROAD_INFO"].ToString(), reader["CARRIER_ID"].ToString(), reader["EQUIPMENT_LICENCE"].ToString(), reader["DRIVER_ID"].ToString(), reader["DRIVER_PHONE"].ToString(), reader["REMARK"].ToString(), reader["UDF1"].ToString(), reader["UDF2"].ToString(), reader["UDF3"].ToString(), reader["UDF4"].ToString(), reader["UDF5"].ToString(), reader["UDF6"].ToString(), reader["UDF7"].ToString(), reader["UDF8"].ToString(), reader["UDF9"].ToString(), reader["UDF10"].ToString(), reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00003 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime());
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return trackingDetailInfo;
        }

        public DataSet GetTrackingDetailByQueryList(List<string> sqlWhere, TrackingDetailQueryEntity trackingdetailQuery, string whLoginID)
        {
            string temp = this.SQL_SELECT_ALL_TRACKING_DETAIL.Replace("@_@", whLoginID);
            for (int i = 0; i < sqlWhere.Count; i++)
            {
                if (i == 0)
                {
                    temp = temp + " WHERE " + sqlWhere[i].ToString();
                }
                else
                {
                    temp = temp + " AND " + sqlWhere[i].ToString();
                }
            }
            if (!trackingdetailQuery.IsGetAll)
            {
                temp = PagingHelper.GetPagingSQL(temp, trackingdetailQuery.CurrentPage, trackingdetailQuery.PageSize, trackingdetailQuery.SortField, trackingdetailQuery.SortDirection);
            }
            return DBHelper.ExecuteDataSet(CommandType.Text, temp);
        }

        public DataSet GetTrackingDetailByQueryList(DataBase dataBase, DbTransaction tran, List<string> sqlWhere, TrackingDetailQueryEntity trackingdetailQuery, string whLoginID)
        {
            string temp = this.SQL_SELECT_ALL_TRACKING_DETAIL.Replace("@_@", whLoginID);
            for (int i = 0; i < sqlWhere.Count; i++)
            {
                if (i == 0)
                {
                    temp = temp + " WHERE " + sqlWhere[i].ToString();
                }
                else
                {
                    temp = temp + " AND " + sqlWhere[i].ToString();
                }
            }
            temp = PagingHelper.GetPagingSQL(temp, trackingdetailQuery.CurrentPage, trackingdetailQuery.PageSize, trackingdetailQuery.SortField, trackingdetailQuery.SortDirection);
            return dataBase.ExecuteDataSet(tran, CommandType.Text, temp);
        }

        public int InsertTrackingDetail(TrackingDetailInfo trackingDetailInfo, List<string> whLoginID)
        {
            int result = 0;
            DataBase db = new DataBase();
            DbConnection conn = db.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    trackingDetailInfo.WhID = whLoginID[i].Substring(0, whLoginID[i].Length - 1);
                    SqlParameter[] paras = this.Set_TrackingDetail_Parameters(trackingDetailInfo);
                    if (paras != null)
                    {
                        result += db.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_TRACKING_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                conn.Close();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int InsertTrackingDetail(DataBase dataBase, DbTransaction tran, TrackingDetailInfo trackingDetailInfo, List<string> whLoginID)
        {
            int result = 0;
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    trackingDetailInfo.WhID = whLoginID[i].Substring(0, whLoginID[i].Length - 1);
                    SqlParameter[] paras = this.Set_TrackingDetail_Parameters(trackingDetailInfo);
                    if (paras != null)
                    {
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_TRACKING_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        private SqlParameter[] Set_TrackingDetail_Parameters(TrackingDetailInfo trackingDetailInfo)
        {
            SqlParameter[] paramArray = new SqlParameter[] { 
                new SqlParameter(this.WH_ID, SqlDbType.VarChar, 30), new SqlParameter(this.TRACKING_ID, SqlDbType.VarChar, 20), new SqlParameter(this.BOL_ID, SqlDbType.VarChar, 20), new SqlParameter(this.DELIVERY_ORDER_ID, SqlDbType.VarChar, 20), new SqlParameter(this.TRACKING_DATE, SqlDbType.DateTime, 8), new SqlParameter(this.TRACKING_LOC, SqlDbType.VarChar, 20), new SqlParameter(this.ACCEPT_MODE, SqlDbType.VarChar, 20), new SqlParameter(this.ROAD_INFO, SqlDbType.VarChar, 20), new SqlParameter(this.CARRIER_ID, SqlDbType.VarChar, 20), new SqlParameter(this.EQUIPMENT_LICENCE, SqlDbType.VarChar, 20), new SqlParameter(this.DRIVER_ID, SqlDbType.VarChar, 20), new SqlParameter(this.DRIVER_PHONE, SqlDbType.VarChar, 20), new SqlParameter(this.REMARK, SqlDbType.VarChar, 100), new SqlParameter(this.UDF1, SqlDbType.VarChar, 30), new SqlParameter(this.UDF2, SqlDbType.VarChar, 30), new SqlParameter(this.UDF3, SqlDbType.VarChar, 30), 
                new SqlParameter(this.UDF4, SqlDbType.VarChar, 30), new SqlParameter(this.UDF5, SqlDbType.VarChar, 30), new SqlParameter(this.UDF6, SqlDbType.VarChar, 30), new SqlParameter(this.UDF7, SqlDbType.VarChar, 30), new SqlParameter(this.UDF8, SqlDbType.VarChar, 30), new SqlParameter(this.UDF9, SqlDbType.VarChar, 30), new SqlParameter(this.UDF10, SqlDbType.VarChar, 30), new SqlParameter(this.CREATED_BY, SqlDbType.VarChar, 30), new SqlParameter(this.UPDATED_BY, SqlDbType.VarChar, 30)
             };
            if (!string.IsNullOrEmpty(trackingDetailInfo.WhID))
            {
                paramArray[0].Value = trackingDetailInfo.WhID;
            }
            else
            {
                paramArray[0].Value = DBNull.Value;
            }
            paramArray[1].Value = trackingDetailInfo.TrackingID;
            paramArray[2].Value = trackingDetailInfo.BolID;
            paramArray[3].Value = trackingDetailInfo.DeliveryOrderID;
            paramArray[4].Value = trackingDetailInfo.TrackingDate;
            paramArray[5].Value = trackingDetailInfo.TrackingLoc;
            paramArray[6].Value = trackingDetailInfo.AcceptMode;
            if (!string.IsNullOrEmpty(trackingDetailInfo.RoadInfo))
            {
                paramArray[7].Value = trackingDetailInfo.RoadInfo;
            }
            else
            {
                paramArray[7].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(trackingDetailInfo.CarrierID))
            {
                paramArray[8].Value = trackingDetailInfo.CarrierID;
            }
            else
            {
                paramArray[8].Value = DBNull.Value;
            }
            paramArray[9].Value = trackingDetailInfo.EquipmentLicence;
            paramArray[10].Value = trackingDetailInfo.DriverID;
            if (!string.IsNullOrEmpty(trackingDetailInfo.DriverPhone))
            {
                paramArray[11].Value = trackingDetailInfo.DriverPhone;
            }
            else
            {
                paramArray[11].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(trackingDetailInfo.Remark))
            {
                paramArray[12].Value = trackingDetailInfo.Remark;
            }
            else
            {
                paramArray[12].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(trackingDetailInfo.Udf1))
            {
                paramArray[13].Value = trackingDetailInfo.Udf1;
            }
            else
            {
                paramArray[13].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(trackingDetailInfo.Udf2))
            {
                paramArray[14].Value = trackingDetailInfo.Udf2;
            }
            else
            {
                paramArray[14].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(trackingDetailInfo.Udf3))
            {
                paramArray[15].Value = trackingDetailInfo.Udf3;
            }
            else
            {
                paramArray[15].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(trackingDetailInfo.Udf4))
            {
                paramArray[0x10].Value = trackingDetailInfo.Udf4;
            }
            else
            {
                paramArray[0x10].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(trackingDetailInfo.Udf5))
            {
                paramArray[0x11].Value = trackingDetailInfo.Udf5;
            }
            else
            {
                paramArray[0x11].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(trackingDetailInfo.Udf6))
            {
                paramArray[0x12].Value = trackingDetailInfo.Udf6;
            }
            else
            {
                paramArray[0x12].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(trackingDetailInfo.Udf7))
            {
                paramArray[0x13].Value = trackingDetailInfo.Udf7;
            }
            else
            {
                paramArray[0x13].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(trackingDetailInfo.Udf8))
            {
                paramArray[20].Value = trackingDetailInfo.Udf8;
            }
            else
            {
                paramArray[20].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(trackingDetailInfo.Udf9))
            {
                paramArray[0x15].Value = trackingDetailInfo.Udf9;
            }
            else
            {
                paramArray[0x15].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(trackingDetailInfo.Udf10))
            {
                paramArray[0x16].Value = trackingDetailInfo.Udf10;
            }
            else
            {
                paramArray[0x16].Value = DBNull.Value;
            }
            paramArray[0x17].Value = trackingDetailInfo.CreatedBy;
            paramArray[0x18].Value = trackingDetailInfo.UpdatedBy;
            return paramArray;
        }

        public int UpdateTrackingDetail(TrackingDetailInfo trackingDetailInfo, List<string> whLoginID)
        {
            int result = 0;
            DataBase db = new DataBase();
            DbConnection conn = db.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    trackingDetailInfo.WhID = whLoginID[i].Substring(0, whLoginID[i].Length - 1);
                    SqlParameter[] paras = this.Set_TrackingDetail_Parameters(trackingDetailInfo);
                    if (paras != null)
                    {
                        result += db.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_TRACKING_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                conn.Close();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int UpdateTrackingDetail(DataBase dataBase, DbTransaction tran, TrackingDetailInfo trackingDetailInfo, List<string> whLoginID)
        {
            int result = 0;
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    trackingDetailInfo.WhID = whLoginID[i].Substring(0, whLoginID[i].Length - 1);
                    SqlParameter[] paras = this.Set_TrackingDetail_Parameters(trackingDetailInfo);
                    if (paras != null)
                    {
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_TRACKING_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }
    }
}

